#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:Taotie Ren

#abs 绝对值
# n = abs(-1)
# print(n)


# all()
# any()
#0.None, "",[],() False
# print(bool(()))
# 所有为真，才为真
# n = all([1,2,3,None])
# print(n)
# 只要有真，就为真
# n = any([],0,"",None)
# print(n)


# ascii() #自动执行对象的 __repr__ 方式
# class Foo:
#     def __repr__(self):
#         return "111"
#
# n = ascii(Foo())
# print(n)


# bin()   十进制===》二进制
# oct()   十进制===》八进制
# hex()   十进制===》十六进制
# print(bin(5))
# print(oct(9))
# print(hex(15))


#utf-8 一个汉字：三个字节
#gbk 一个汉字：二个字节
#utf-8
#字符串转换字节类型
# bytes(需要转换的字符串，按照什么编码)
# s ="李杰"
# n = bytes(s,encoding="utf-8")
# print(n)
# n = bytes(s,encoding="gbk")
# print(n)
# 字节转换成字符串
# s = str(bytes("李杰",encoding="utf-8"),encoding="utf-8")
# print(s)


#1.打开文件
# #只读
# f = open('db','r')
# #只写，先清空原文件
# f = open('db','w')
# #如果文件存在就报错，不存在创建并写内容 python3
# f = open('db','x')
# #追加
# f = open('db','a')
#以字节打开
# f = open('db','r',encoding= "utf-8")
# data = f.read()
# print(data)
# f.close()
# # 以二进制打开
# f = open('db','rb')
# data = f.read()
# print(data,type(data))
# f.close()

# f = open('db','ab')
# f.write(bytes("hello",encoding="utf-8"))
# f.close()
#

# 以二进制打开
# f = open('db','r+',encoding="utf-8")
# data = f.read()
# print(data)
# f.write("666")
# f.close()


#2.操作文件
#通过源码查看功能


#3.关闭文件
# f.close()
# with open('qq') as f:
#     pass
#
#






















